/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import Entity.CTNhanVienQuyen;
import Util.DatabaseHandle;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Dark_Knight
 */
public class CTNhanVienQuyenImpl implements CTNhanVienQuyenDAO {

    public boolean add(CTNhanVienQuyen data) {
        String sql = "{call sp_CT_NV_QUYEN_add(?,?)}";
        DatabaseHandle db = new DatabaseHandle(sql, true);
        
        try {
            db.setParameter(1, data.getMaNhanVien());
            db.setParameter(2, data.getMaQuyen());
            db.executeStorePro();
            db.closed();
            return true;
        } catch (SQLException ex) {
            Logger.getLogger(CTNhanVienQuyenImpl.class.getName()).log(Level.SEVERE, null, ex);
            db.closed();
            return false;
        }
    }

    public boolean delete(int MaNhanVien) {
        String sql = "{call sp_CT_NV_QUYEN_delete(?)}";
        DatabaseHandle db = new DatabaseHandle(sql, true);
        try {
            db.setParameter(1, MaNhanVien);
            db.executeStorePro();
            db.closed();
            return true;
        } catch (SQLException ex) {
            Logger.getLogger(CTNhanVienQuyenImpl.class.getName()).log(Level.SEVERE, null, ex);
            db.closed();
            return false;
        }
    }

    public boolean edit(CTNhanVienQuyen data) {
        String sql = "{call sp_CT_NV_QUYEN_edit(?,?)}";
        DatabaseHandle db = new DatabaseHandle(sql, true);
        
        try {
            db.setParameter(1, data.getMaNhanVien());
            db.setParameter(2, data.getMaQuyen());
            db.executeStorePro();
            db.closed();
            return true;
        } catch (SQLException ex) {
            Logger.getLogger(CTNhanVienQuyenImpl.class.getName()).log(Level.SEVERE, null, ex);
            db.closed();
            return false;
        }
    }
        
}
